<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>权限框架</title>
    <link rel="stylesheet" type="text/css" href="/css/style.css">
    <!--[if lt IE 9]>
    <script src="/js/html5.js"></script>
    <![endif]-->
    <script src="/js/jquery.js"></script>
    <script src="/js/jquery.mCustomScrollbar.concat.min.js"></script>
    <script>
        $(function method(val) {
            $("#roleCode").focus(function () {
                if ($(this).val() === '请输入角色编码')
                    $(this).val("");
            }).blur(function () {
                if ($(this).val() === "" || $(this).val() == null) {
                    $("#roleCodeInfo").html("角色编码不能为空");
                } else if ($(this).val() !== "" || $(this).val() != null) {
                    $("#roleCodeInfo").html("");
                }
            });
            $("#roleName").focus(function () {
                if ($(this).val() === '请输入角色名')
                    $(this).val("");
            }).blur(function () {
                if ($(this).val() === "" || $(this).val() == null) {
                    $("#roleNameInfo").html("角色名不能为空");
                } else if ($(this).val() !== "" || $(this).val() != null) {
                    $("#roleNameInfo").html("");
                }
            });
        })
    </script>
    <script>
        function check () {
            var rcode =$("#roleCodeInfo").html();
            var rname =$("#roleNameInfo").html();
            if (rcode!==""||rname!==""){
                alert("添加失败！请检查信息")
                return false;
            }else{
                alert("成功添加角色")
                return true;
            }
        }
    </script>
</head>
<body>
<div th:replace="head::header"></div>
<div class="rt_content">
    <div class="rt_content">
        <div class="page_title">
            <h2 class="fl">添加用户</h2>
        </div>
        <div class="providerAdd">
            <div id="contents" class="contents" style="color:red;margin-bottom: 20px;margin-left: 250px;" ></div>
            <form id="userForm" name="userForm" method="post" class="container container-small" th:action="@{/user/add_role(createBy=${session.userinfo.id})}" onsubmit="return check();">
                <div class="form-group">
                    <label for="roleCode">角色编码：</label>
                    <a style="color: red">*</a>
                    <input type="text" name="roleCode" id="roleCode" value="请输入角色编码"><span style="color: red" id="roleCodeInfo"></span>
                    <!-- 放置提示信息 -->
                    <font color="red"></font>
                </div >
                <div class="form-group">
                    <label for="roleName">角色名称：</label>
                    <a style="color: red">*</a>
                    <input type="text" name="roleName" id="roleName" value="请输入角色名"><span style="color: red" id="roleNameInfo"></span>
                    <font color="red"></font>
                </div>
                <div class="providerAddBtn">
                    <button type="submit" class="btn btn-primary" th:onclick="method(${session.userinfo.id})" ><a class="btn btn-primary">保存</a></button>
                        <button><a type="button" class="btn btn-default" data-dismiss="modal" th:href="@{/toIndex}">返回</a></button>
                </div>
            </form>
        </div>
    </div>
    </section>
</body>
</html>